<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>

<title>aem | 8. Examples</title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<style type="text/css" media="all"><!--@import url(full.css);--></style>

</head>
<body>

<h1>8. Examples</h1>

<!-- top navigation -->
<div class="navbar">
	<a href="07_findapp.html">Previous</a> | <a href="index.html">Up</a>
</div>

<!-- content -->
<div id="content">


<h2>Identifying applications</h2>

<pre><code># application "Macintosh HD:Applications:TextEdit.app"
textedit = AEM::Application.by_path('/Applications/TextEdit.app')

# application "TextEdit"
textedit = AEM::Application.by_path(FindApp.by_name('TextEdit'))

# application "TextEdit" of machine "eppc://my-mac.local"
textedit = AEM::Application.by_url('eppc://my-mac.local/TextEdit')</code></pre>


<h2>Building references</h2>

<pre><code># name (of application)
AEM.app.property('pnam')

# text of every document
AEM.app.elements('docu').property('ctxt')

# end of every paragraph of text of document 1
AEM.app.elements('docu').by_index(1).property('ctxt').elements('cpar').end

# paragraphs 2 thru last of first document
AEM.app.elements('docu').first.elements('cpar').by_range(
        AEM.con.elements('cpar').by_index(2), 
        AEM.con.elements('cpar').last)

# paragraphs of document 1 where it != "\n"
AEM.app.elements('docu').by_index(1).elements('cpar').by_filter(AEM.its.ne("\n"))</code></pre>


<h2>Sending events</h2>

<pre><code># quit TextEdit
textedit.event('corequit').send

# name of TextEdit
p textedit.event('coregetd', {'----' =&gt; AEM.app.property('pnam')}).send

# count documents of TextEdit
p textedit.event('corecnte', {'----' =&gt; AEM.app.elements('docu')}).send

# make new document at end of documents of TextEdit
textedit.event('corecrel', {
        'kocl' =&gt; AEM::AEType.new('docu'), 
        'insh' =&gt; AEM.app.elements('docu').end
        }).send</code></pre>



</div>

<!-- bottom navigation -->
<div class="navbar">
	<a href="07_findapp.html">Previous</a> | <a href="index.html">Up</a>
</div>

<!--footer-->
<p class="footer">&copy; 2006 HAS</p>
</body>
</html>